/*
 * 单选框组件
 */
const radioTemplate = `
<div class="radio-box">
  <input type="radio" :checked="isCheck" @change="change" name="default" :id="label">
  <label :for="label" class="radio-stype radio"></label> <span> <slot /> </span>
</div>
`;
Vue.component("my-radio", {
  template: radioTemplate,
  props: ["label", "value"],
  // TODO 请在此继续完成该组件的代码编写
  data() {
    return {
      isCheck: false,
    };
  },
  watch: {
    value() {
      this.checkMatch();
    },
  },
  mounted() {
    this.checkMatch();
  },
  methods: {
    checkMatch() {
      this.isCheck = this.label == this.value;
    },
    change() {
      this.$emit("input", this.label);
    },
  },
});
